package com.javaProject.controller;


import com.javaProject.dto.R;
import com.javaProject.entity.Bishe;
import com.javaProject.entity.Xuanze;
import com.javaProject.service.BisheService;
import com.javaProject.service.XuanzeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@Tag(name="毕设接口",description = "这个接口的目的主要用于增删改查")
@RestController
public class bisheController {
    @Autowired
    private BisheService bisheService;

    @Autowired
    private XuanzeService xuanzeService;


    @Operation(summary = "毕设删除",description = "提供毕设id")
    @GetMapping("/bishe/del")
    public R Delect(@RequestParam("bisheId") int bisheId){
        Bishe bishe = new Bishe();
        bishe.setBisheId(bisheId);
        return bisheService.Delect(bishe);
    }


    @Operation(summary = "毕设整体查询",description = "无需提供数据")
    @PostMapping("/bishe/All")
    public List<Bishe> getAllBishe(){
        return bisheService.getAllBishe();
    }


    @Operation(summary = "毕设新增",description = "需要提供毕设内容的所有数据")
    @Parameters({
        @Parameter(name ="bisheName",description = "毕设名字",required = true),
        @Parameter(name = "teacherId",description = "教师id",required = true),
        @Parameter(name = "teachaerName",description = "教师名字",required = true),
        @Parameter(name = "content",description = "主要内容",required = true),
        @Parameter(name = "univercity",description = "所属院校",required = true),
        @Parameter(name = "major",description = "专业",required = true),
        @Parameter(name = "teacherSays",description = "老师备注",required = true),
    })
    @PostMapping("/bishe")
    public R add(@RequestBody Bishe bishe){
        return bisheService.add(bishe);
    }


    @Operation(summary = "毕设整体修改",description = "需要提供所有信息类似于上传")
    @Parameters({
            @Parameter(name ="bisheName",description = "毕设名字",required = true),
            @Parameter(name = "teacherId",description = "教师id",required = true),
            @Parameter(name = "teacherName",description = "教师名字",required = true),
            @Parameter(name = "content",description = "主要内容",required = true),
            @Parameter(name = "univercity",description = "所属院校",required = true),
            @Parameter(name = "major",description = "专业",required = true),
            @Parameter(name = "teacherSays",description = "老师备注",required = true),
    })
    @PutMapping("/bishe/upData")
    public R upData(@RequestBody Bishe bishe){
        return bisheService.upData(bishe);
    }


    @Operation(summary = "毕设isLock状态修改",description = "需要提供毕设id和状态码")
    @Parameters({
            @Parameter(name ="bisheId",description = "毕设id",required = true),
            @Parameter(name = "isPass",description = "毕设状态",required = true),
    })
    @PostMapping("/bishe/upDataIsPass")
    public R upDataIsPass(@RequestBody Bishe bishe){
        return bisheService.upDataIsPass(bishe);
    }



    @Operation(summary = "毕设isPASS状态修改",description = "需要提供毕设id和状态码")
    @Parameters({
            @Parameter(name ="bisheId",description = "毕设id",required = true),
            @Parameter(name = "isLock",description = "双向锁定学生学号",required = true),
    })
    @PostMapping("/bishe/upDataIsLock")
    public R upDataIsLocek(@RequestBody Bishe bishe){
        Xuanze xuanze = new Xuanze();
        xuanze.setBisheId(bishe.getBisheId());
        xuanzeService.Delect(xuanze);
        return  bisheService.upDataIsLock(bishe);
    }

    @Operation(summary = "查询单个教师毕设",description = "需要提供所查询的教师ID")
    @Parameter(name = "teacherId",description = "教师ID",required = true)
    @PostMapping("/bishe/getTeacherBishe")
    public List<Bishe> getTeacherBishe(@RequestBody Bishe bishe){
        return bisheService.getTeacherBishe(bishe);
    }

    @Operation(summary = "查询通过不同类型",description = "需要提供Ispass状态")
    @PostMapping("/bishe/getIspssBishe")
    public List<Bishe> getIslockBishe(@RequestBody Bishe bishe){
        return bisheService.getIsLockBishe(bishe);
    }


}


